#include <string>
#include <vector>
#include <iostream>

using namespace std;

// a b b a

// s = a b e b a
// 如果 s 是回文
// s[0] == s[3] 两头的字符相等
// s[1] == s[2] 中间的字符串是回文
// 如果一个字符串两端字符相等，中间的字符串是回文，那么这个字符串就是回文。
//

int main(int argc, char const *argv[])
{
  /* code */
  string s;
  cin >> s;

  int n = s.length();

  if (n == 0 || n == 1) {
    cout << n << endl;
  }

  vector<bool> line(n, false);
  vector<vector<bool>> records(n, line);

  int maxLen = 1, b = 0, e = 0;

  for (int i = 0; i < n; ++i) {
    records[i][i] = true;
  }

  int step = 1;

  while (step < n) {
    for (int i = 0; i <= n - step - 1; ++i) {
      // i - 小字符串的起始位置
      int j = i + step;
      // j - 小字符串的结束位置

      if (step == 1) {
        // 两个字符的情况
        records[i][j] = (s[i] == s[j]);
      }
      else {
        records[i][j] = (s[i] == s[j] && records[i + 1][j - 1]);
      }

      if (records[i][j] && step + 1 > maxLen) {
        maxLen = step + 1;
        b = i;
        e = j;
      }
    }

    ++step;
  }

  cout << maxLen << endl;
  cout << s.substr(b, maxLen) << endl;

  return 0;
}
